
#import "ReverseModule.h"
#import "Imports.h"


@implementation ReverseModule

- ReverseIt:sender
{
	id Currentsound=[TheModuleController CurrentSound:self];
	int DataFormat=[Currentsound dataFormat];
	
	
	if ((DataFormat==SND_FORMAT_MULAW_8)||
		(DataFormat==SND_FORMAT_MULAW_SQUELCH)||
		(DataFormat==SND_FORMAT_LINEAR_8)||
		(DataFormat==SND_FORMAT_DSP_DATA_8) )
		
		
		{	
		char *TheSamples;
		int NumberOfSamples;
		int x;
		char Trader;
		if ([TheModuleController RunCompactPanel:self]);
			{
			[Currentsound compactSamples];
			TheSamples=(char *)[Currentsound data];
			NumberOfSamples=[Currentsound sampleCount];
			for (x=0;x<(NumberOfSamples-1)/2;x++)
				{
				Trader=TheSamples[x];
				TheSamples[x]=TheSamples[NumberOfSamples-x];
				TheSamples[NumberOfSamples-x]=Trader;
				}
			[TheModuleController SoundChanged:Currentsound];
			return self;
			}
		}
		
	else
		
		{
		short int *TheSamples;
		int NumberOfSamples;
		int x;
		short int Trader;
		if ([TheModuleController RunCompactPanel:self]);
			{
			[Currentsound compactSamples];
			TheSamples=(short int *)[Currentsound data];
			NumberOfSamples=[Currentsound sampleCount];
			for (x=0;x<(NumberOfSamples-1)/2;x++)
				{
				Trader=TheSamples[x];
				TheSamples[x]=TheSamples[NumberOfSamples-x];
				TheSamples[NumberOfSamples-x]=Trader;
				}
			[TheModuleController SoundChanged:Currentsound];
			return self;
			}
		}

	
}


@end
